<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Users extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idusers;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idpere;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Idtypeusers;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idgoverneras;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Idfonctionresp;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Login;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Motpasse;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Nom;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Prenom;

    /**
     * Database var type tinyint(4)
     *
     * @var int
     */
    protected $_Delegation;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Email;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_Tel;


    /**
     * Parent relation fk_users_users
     *
     * @var Application_Model_Users
     */
    protected $_UsersByIdpere;

    /**
     * Parent relation fk_users_typeusers1
     *
     * @var Application_Model_Typeusers
     */
    protected $_Typeusers;

    /**
     * Parent relation fk_users_governeras1
     *
     * @var Application_Model_Governeras
     */
    protected $_Governeras;

    /**
     * Parent relation fk_users_fonctionresp1
     *
     * @var Application_Model_Fonctionresp
     */
    protected $_Fonctionresp;


    /**
     * Dependent relation fk_droitfeuille_users1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Droitfeuille
     */
    protected $_Droitfeuille;

    /**
     * Dependent relation fk_fichiertransferet_users1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Fichiertransferet
     */
    protected $_Fichiertransferet;

    /**
     * Dependent relation fk_users_users
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Users
     */
    protected $_Users;

    /**
     * Dependent relation fk_usersprojets_users1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Usersprojets
     */
    protected $_Usersprojets;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idusers'=>'Idusers',
            'idpere'=>'Idpere',
            'idtypeusers'=>'Idtypeusers',
            'idgoverneras'=>'Idgoverneras',
            'idfonctionresp'=>'Idfonctionresp',
            'login'=>'Login',
            'motpasse'=>'Motpasse',
            'nom'=>'Nom',
            'prenom'=>'Prenom',
            'delegation'=>'Delegation',
            'email'=>'Email',
            'tel'=>'Tel',
        ));

        $this->setParentList(array(
            'FkUsersUsers'=> array(
                    'property' => 'UsersByIdpere',
                    'table_name' => 'Users',
                ),
            'FkUsersTypeusers1'=> array(
                    'property' => 'Typeusers',
                    'table_name' => 'Typeusers',
                ),
            'FkUsersGoverneras1'=> array(
                    'property' => 'Governeras',
                    'table_name' => 'Governeras',
                ),
            'FkUsersFonctionresp1'=> array(
                    'property' => 'Fonctionresp',
                    'table_name' => 'Fonctionresp',
                ),
        ));

        $this->setDependentList(array(
            'FkDroitfeuilleUsers1' => array(
                    'property' => 'Droitfeuille',
                    'table_name' => 'Droitfeuille',
                ),
            'FkFichiertransferetUsers1' => array(
                    'property' => 'Fichiertransferet',
                    'table_name' => 'Fichiertransferet',
                ),
            'FkUsersUsers' => array(
                    'property' => 'Users',
                    'table_name' => 'Users',
                ),
            'FkUsersprojetsUsers1' => array(
                    'property' => 'Usersprojets',
                    'table_name' => 'Usersprojets',
                ),
        ));
    }

    /**
     * Sets column idusers
     *
     * @param int $data
     * @return Application_Model_Users
     */
    public function setIdusers($data)
    {
        $this->_Idusers = $data;
        return $this;
    }

    /**
     * Gets column idusers
     *
     * @return int
     */
    public function getIdusers()
    {
        return $this->_Idusers;
    }

    /**
     * Sets column idpere
     *
     * @param int $data
     * @return Application_Model_Users
     */
    public function setIdpere($data)
    {
        $this->_Idpere = $data;
        return $this;
    }

    /**
     * Gets column idpere
     *
     * @return int
     */
    public function getIdpere()
    {
        return $this->_Idpere;
    }

    /**
     * Sets column idtypeusers
     *
     * @param string $data
     * @return Application_Model_Users
     */
    public function setIdtypeusers($data)
    {
        $this->_Idtypeusers = $data;
        return $this;
    }

    /**
     * Gets column idtypeusers
     *
     * @return string
     */
    public function getIdtypeusers()
    {
        return $this->_Idtypeusers;
    }

    /**
     * Sets column idgoverneras
     *
     * @param int $data
     * @return Application_Model_Users
     */
    public function setIdgoverneras($data)
    {
        $this->_Idgoverneras = $data;
        return $this;
    }

    /**
     * Gets column idgoverneras
     *
     * @return int
     */
    public function getIdgoverneras()
    {
        return $this->_Idgoverneras;
    }

    /**
     * Sets column idfonctionresp
     *
     * @param string $data
     * @return Application_Model_Users
     */
    public function setIdfonctionresp($data)
    {
        $this->_Idfonctionresp = $data;
        return $this;
    }

    /**
     * Gets column idfonctionresp
     *
     * @return string
     */
    public function getIdfonctionresp()
    {
        return $this->_Idfonctionresp;
    }

    /**
     * Sets column login
     *
     * @param string $data
     * @return Application_Model_Users
     */
    public function setLogin($data)
    {
        $this->_Login = $data;
        return $this;
    }

    /**
     * Gets column login
     *
     * @return string
     */
    public function getLogin()
    {
        return $this->_Login;
    }

    /**
     * Sets column motpasse
     *
     * @param string $data
     * @return Application_Model_Users
     */
    public function setMotpasse($data)
    {
        $this->_Motpasse = $data;
        return $this;
    }

    /**
     * Gets column motpasse
     *
     * @return string
     */
    public function getMotpasse()
    {
        return $this->_Motpasse;
    }

    /**
     * Sets column nom
     *
     * @param string $data
     * @return Application_Model_Users
     */
    public function setNom($data)
    {
        $this->_Nom = $data;
        return $this;
    }

    /**
     * Gets column nom
     *
     * @return string
     */
    public function getNom()
    {
        return $this->_Nom;
    }

    /**
     * Sets column prenom
     *
     * @param string $data
     * @return Application_Model_Users
     */
    public function setPrenom($data)
    {
        $this->_Prenom = $data;
        return $this;
    }

    /**
     * Gets column prenom
     *
     * @return string
     */
    public function getPrenom()
    {
        return $this->_Prenom;
    }

    /**
     * Sets column delegation
     *
     * @param int $data
     * @return Application_Model_Users
     */
    public function setDelegation($data)
    {
        $this->_Delegation = $data;
        return $this;
    }

    /**
     * Gets column delegation
     *
     * @return int
     */
    public function getDelegation()
    {
        return $this->_Delegation;
    }

    /**
     * Sets column email
     *
     * @param text $data
     * @return Application_Model_Users
     */
    public function setEmail($data)
    {
        $this->_Email = $data;
        return $this;
    }

    /**
     * Gets column email
     *
     * @return text
     */
    public function getEmail()
    {
        return $this->_Email;
    }

    /**
     * Sets column tel
     *
     * @param string $data
     * @return Application_Model_Users
     */
    public function setTel($data)
    {
        $this->_Tel = $data;
        return $this;
    }

    /**
     * Gets column tel
     *
     * @return string
     */
    public function getTel()
    {
        return $this->_Tel;
    }

    /**
     * Sets parent relation Idpere
     *
     * @param Application_Model_Users $data
     * @return Application_Model_Users
     */
    public function setUsersByIdpere(Application_Model_Users $data)
    {
        $this->_UsersByIdpere = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idusers'];
        }

        $this->setIdpere($primary_key);

        return $this;
    }

    /**
     * Gets parent Idpere
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Users
     */
    public function getUsersByIdpere($load = true)
    {
        if ($this->_UsersByIdpere === null && $load) {
            $this->getMapper()->loadRelated('FkUsersUsers', $this);
        }

        return $this->_UsersByIdpere;
    }

    /**
     * Sets parent relation Idtypeusers
     *
     * @param Application_Model_Typeusers $data
     * @return Application_Model_Users
     */
    public function setTypeusers(Application_Model_Typeusers $data)
    {
        $this->_Typeusers = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idtypeusers'];
        }

        $this->setIdtypeusers($primary_key);

        return $this;
    }

    /**
     * Gets parent Idtypeusers
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Typeusers
     */
    public function getTypeusers($load = true)
    {
        if ($this->_Typeusers === null && $load) {
            $this->getMapper()->loadRelated('FkUsersTypeusers1', $this);
        }

        return $this->_Typeusers;
    }

    /**
     * Sets parent relation Idgoverneras
     *
     * @param Application_Model_Governeras $data
     * @return Application_Model_Users
     */
    public function setGoverneras(Application_Model_Governeras $data)
    {
        $this->_Governeras = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idgoverneras'];
        }

        $this->setIdgoverneras($primary_key);

        return $this;
    }

    /**
     * Gets parent Idgoverneras
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Governeras
     */
    public function getGoverneras($load = true)
    {
        if ($this->_Governeras === null && $load) {
            $this->getMapper()->loadRelated('FkUsersGoverneras1', $this);
        }

        return $this->_Governeras;
    }

    /**
     * Sets parent relation Idfonctionresp
     *
     * @param Application_Model_Fonctionresp $data
     * @return Application_Model_Users
     */
    public function setFonctionresp(Application_Model_Fonctionresp $data)
    {
        $this->_Fonctionresp = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idfonctionresp'];
        }

        $this->setIdfonctionresp($primary_key);

        return $this;
    }

    /**
     * Gets parent Idfonctionresp
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Fonctionresp
     */
    public function getFonctionresp($load = true)
    {
        if ($this->_Fonctionresp === null && $load) {
            $this->getMapper()->loadRelated('FkUsersFonctionresp1', $this);
        }

        return $this->_Fonctionresp;
    }

    /**
     * Sets dependent relations fk_droitfeuille_users1
     *
     * @param array $data An array of Application_Model_Droitfeuille
     * @return Application_Model_Users
     */
    public function setDroitfeuille(array $data)
    {
        $this->_Droitfeuille = array();

        foreach ($data as $object) {
            $this->addDroitfeuille($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_droitfeuille_users1
     *
     * @param Application_Model_Droitfeuille $data
     * @return Application_Model_Users
     */
    public function addDroitfeuille(Application_Model_Droitfeuille $data)
    {
        $this->_Droitfeuille[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_droitfeuille_users1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Droitfeuille
     */
    public function getDroitfeuille($load = true)
    {
        if ($this->_Droitfeuille === null && $load) {
            $this->getMapper()->loadRelated('FkDroitfeuilleUsers1', $this);
        }

        return $this->_Droitfeuille;
    }

    /**
     * Sets dependent relations fk_fichiertransferet_users1
     *
     * @param array $data An array of Application_Model_Fichiertransferet
     * @return Application_Model_Users
     */
    public function setFichiertransferet(array $data)
    {
        $this->_Fichiertransferet = array();

        foreach ($data as $object) {
            $this->addFichiertransferet($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_fichiertransferet_users1
     *
     * @param Application_Model_Fichiertransferet $data
     * @return Application_Model_Users
     */
    public function addFichiertransferet(Application_Model_Fichiertransferet $data)
    {
        $this->_Fichiertransferet[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_fichiertransferet_users1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Fichiertransferet
     */
    public function getFichiertransferet($load = true)
    {
        if ($this->_Fichiertransferet === null && $load) {
            $this->getMapper()->loadRelated('FkFichiertransferetUsers1', $this);
        }

        return $this->_Fichiertransferet;
    }

    /**
     * Sets dependent relations fk_users_users
     *
     * @param array $data An array of Application_Model_Users
     * @return Application_Model_Users
     */
    public function setUsers(array $data)
    {
        $this->_Users = array();

        foreach ($data as $object) {
            $this->addUsers($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_users_users
     *
     * @param Application_Model_Users $data
     * @return Application_Model_Users
     */
    public function addUsers(Application_Model_Users $data)
    {
        $this->_Users[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_users_users
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Users
     */
    public function getUsers($load = true)
    {
        if ($this->_Users === null && $load) {
            $this->getMapper()->loadRelated('FkUsersUsers', $this);
        }

        return $this->_Users;
    }

    /**
     * Sets dependent relations fk_usersprojets_users1
     *
     * @param array $data An array of Application_Model_Usersprojets
     * @return Application_Model_Users
     */
    public function setUsersprojets(array $data)
    {
        $this->_Usersprojets = array();

        foreach ($data as $object) {
            $this->addUsersprojets($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_usersprojets_users1
     *
     * @param Application_Model_Usersprojets $data
     * @return Application_Model_Users
     */
    public function addUsersprojets(Application_Model_Usersprojets $data)
    {
        $this->_Usersprojets[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_usersprojets_users1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Usersprojets
     */
    public function getUsersprojets($load = true)
    {
        if ($this->_Usersprojets === null && $load) {
            $this->getMapper()->loadRelated('FkUsersprojetsUsers1', $this);
        }

        return $this->_Usersprojets;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Users
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Users());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Users::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdusers() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idusers = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdusers()));
    }
}
